from bokeh.plotting import figure ,show
import random
from bokeh.palettes import Turbo256
from bokeh.transform import linear_cmap

# x=[1,2,3,4,5]
# y=[6,7,1,2,5]
# #创建画布
# p=figure(title='一个图',x_axis_label='横轴')
# # 画图
# p.line(x,y)
# # 显示
# show(p)

# x=list(range(0,26))
# y=random.sample(range(0,100),26)
# # 配置颜色
# colors=[f'#{255:02x}{int(v* 255 /100):02x}{255:02x}' for v in y]
# # 创建画布
# p=figure(max_width=500,height=250)
# p.line(x,y,line_color='blue',line_width=1)
# p.circle(x,y,fill_color=colors,size=15)
# show(p)

x=list(range(-32,33))
y=[i ** 2 for i in x]
cmap=linear_cmap(field_name='y',palette=Turbo256,low=min(y),high=max(y)) # 关联颜色和y的值
p=figure(width=500,height=250)
p.circle(x,y,color=cmap,size=10)
show(p)